﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using UnityEngine;

public static class StreamingAssetUtility
{
    [CompilerGenerated]
    private static Func<StreamingAsset, string> <>f__am$cache0;

    public static bool EqualsIgnoreCase(string a, string b)
    {
        return (a.ToLower() == b.ToLower());
    }

    public static IEnumerable<IGrouping<string, StreamingAsset>> GroupBySequence(this IEnumerable<StreamingAsset> assets)
    {
        if (<>f__am$cache0 == null)
        {
            <>f__am$cache0 = x => Regex.Replace(x.name, @"\d*$", string.Empty);
        }
        return assets.GroupBy<StreamingAsset, string>(<>f__am$cache0);
    }

    public static bool IsAnyExtension(string path, params string[] extentions)
    {
        <IsAnyExtension>c__AnonStorey96 storey = new <IsAnyExtension>c__AnonStorey96 {
            path = path
        };
        return extentions.Any<string>(new Func<string, bool>(storey.<>m__1AB));
    }

    public static bool IsInTheFolder(string path, string folderPath)
    {
        return path.ToLower().StartsWith(folderPath.ToLower());
    }

    public static WWW Load(string path)
    {
        WWW www = new WWW(ToStreamingAssetsUrl(path));
        while (!www.isDone)
        {
        }
        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.LogError(www.error);
        }
        return www;
    }

    public static string ToStreamingAssetsUrl(string path)
    {
        path = path.Replace(@"\", "/").ToLower();
        string str = "file://";
        string str2 = Application.streamingAssetsPath.ToLower() + "/";
        if (!path.StartsWith(str + str2) && path.StartsWith(str2))
        {
            return (str + path);
        }
        return path;
    }

    [CompilerGenerated]
    private sealed class <IsAnyExtension>c__AnonStorey96
    {
        internal string path;

        internal bool <>m__1AB(string x)
        {
            return (x.ToLower() == Path.GetExtension(this.path).ToLower());
        }
    }
}

